package service.back;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import model.generate.SyncProject;
import model.vo.PageResult;
import utils.Page;
import dao.generate.SyncProjectDao;

public class SyncProjectBackService{

	SyncProjectDao svnDao = new SyncProjectDao();
	
	//条件查询(分页)
	public PageResult<SyncProject> findCollectionByConditionWithPage(Map<String,Object> paramMap, Integer pageNum, Integer pageSize) {
		Page<SyncProject> page = new Page<SyncProject>(pageNum,pageSize);
		
		String condition = "";
		List<Object> paramList = new ArrayList<Object>();

		Integer project = Integer.parseInt(paramMap.get("project").toString());
		if(project>0){
			condition += " and project=?";
			paramList.add(project);
		}
		svnDao.findCollectionByConditionWithPage(condition, paramList.toArray(), null, page);
		return new PageResult<SyncProject>(page);
	}
	//保存
		public void save(SyncProject svnproject) {
			svnDao.saveAndCommit(svnproject);
		}
		//更新
		public void update(SyncProject svnproject) {
			svnDao.updateAndCommit(svnproject);
		}
		//删除
		public void delete(SyncProject svnproject){
			svnDao.deleteAndCommit(svnproject);
		}
		//通过id删除记录(可以同时删除多个)
		@SuppressWarnings("all")
		public void deleteByIDs(Integer... ids) {
			svnDao.deleteByIDsAndCommit(ids);
		}
		//根据id查询所有同步信息
		public List<SyncProject> findSyncProjectsByProjectId(Integer id)
		{
			List<SyncProject> projects=svnDao.findCollectionByConditionNoPage("and project=?", new Object[]{id}, null);
			return projects;
		}
	
}